﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="出库单查询.aspx.cs" Inherits="syc.Sale.出库单查询" %>

<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:Label ID="SqlText" runat="server" Text="" Visible="false"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
onselected="SqlDataSource1_Selected" 
DeleteCommand="delete from 产品出库单 where ID=@ID and 是否送检=0;IF @@ROWCOUNT > 0 begin update 产品库存 set 出库单ID=0,状态=1,出库日期=null where 出库单ID=@ID;end"
InsertCommand="update 产品出库单 set 是否送检=@VAL where ID=@ID and 是否合格=0"
UpdateCommand="update 产品出库单 set 是否合格=@VAL where ID=@ID and 是否送检=1"
>
<DeleteParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4"/>
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4"/>
<asp:Parameter Name="VAL" DbType="Boolean" Size="1"/>
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4"/>
<asp:Parameter Name="VAL" DbType="Boolean" Size="1"/>
</UpdateParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="SELECT 0 as [ID], '请选择' as [名称] UNION ALL SELECT [ID], [名称] FROM [产品订货单位]">
</asp:SqlDataSource>

<div id="wintop" class="wintop">产品出库单</div>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">  
    <asp:Button ID="Look" runat="server" Text="产品装车单"  CssClass="button" 
        onclick="Look_Click"/>
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel" GroupingText="产品出库单查询">

 <span style="margin-left:8px;"></span> 
<asp:SqlDataSource ID="DS_ChanPin" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="SELECT 0 AS ID,'全部' as 名称 UNION ALL SELECT [ID],[品名]+' '+[钢级]+' '+[规格] AS 名称 FROM [产品]"></asp:SqlDataSource>
产品类别：<asp:DropDownList ID="ChanPin" runat="server" Width="150px" Font-Size="12px" DataSourceID="DS_ChanPin" DataTextField="名称" DataValueField="ID">

</asp:DropDownList>
    <span style="margin-left:23px;"></span>订货单位：<asp:DropDownList ID="DingHuo" runat="server" 
            DataSourceID="SqlDataSource2" DataTextField="名称" DataValueField="ID" 
            Width="115px" >
        </asp:DropDownList><br>
    <div style="font-size:6px;height:6px;line-height:6px;">
    </div>
    <span style="margin-left:8px;"></span>起始日期：<asp:TextBox ID="Date1" 
        runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img 
        align="middle" alt="" 
        onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" 
        src="/Icons/29.png" /> <span style="margin-left:8px;"></span>截止日期：<asp:TextBox 
        ID="Date2" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img 
        align="middle" alt="" 
        onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" 
        src="/Icons/29.png" />
    <asp:Button ID="Button_Query" runat="server" CssClass="mbutton" 
        onclick="Button_Query_Click" Text="查 询" UseSubmitBehavior="false" />
    <asp:Button ID="Button_Reset" runat="server" CssClass="mbutton" 
        onclick="Button_Reset_Click" Text="清空条件" UseSubmitBehavior="false" />
</asp:Panel>
  <asp:Panel ID="Panel3" runat="server" CssClass="panel2">
        <asp:Label ID="Message" runat="server" Text="·准备就绪" CssClass="prompt"></asp:Label>
    </asp:Panel>

<div class="gridframe">
    <div class="gridview">
    
        <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
            <tr>
	            <td class="grid-title"><div style="float:left;margin-top:3px;">产品出库单</div><div style="float:right;">
                    </div></td>
	        </tr>
	        <tr>
	            <td class="grid-back">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid"  
                        DataSourceID="SqlDataSource1"
                        PageSize="20"
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged">
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>
                        
                            <asp:TemplateField HeaderText="">
                                <ItemTemplate>
                                    <asp:Button ID="Button_xz" runat="server" CommandName="Select" Text="选择" CssClass="hide"/>
                                    <img src="/Icons/online.gif" style="margin-top:2px;" alt="" />
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="20px" />
                            </asp:TemplateField>                                                           
                                
                                <asp:TemplateField HeaderText="产品类别" SortExpression="品名">
                                    <ItemTemplate>
                                        <asp:Label ID="Label3" runat="server" Text='<%# Eval("品名") %>' ></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                                </asp:TemplateField>    
                                        
                                
                                <asp:TemplateField HeaderText="订货单位" SortExpression="发往单位">
                                    <ItemTemplate>
                                        <asp:Label ID="Label5" runat="server" Text='<%# Eval("发往单位") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Left" Width="90px" />
                                </asp:TemplateField>  
                                 
                                <asp:TemplateField HeaderText="捆数" SortExpression="整车捆数">
                                    <ItemTemplate>
                                        <asp:Label ID="Label6" runat="server" Text='<%# Eval("整车捆数") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                                </asp:TemplateField> 
                                
                                <asp:TemplateField HeaderText="支数" SortExpression="整车支数">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_zs" runat="server" Text='<%# Eval("整车支数") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                                </asp:TemplateField> 
                                
                                <asp:TemplateField HeaderText="总重(吨）" SortExpression="整车吨位">
                                    <ItemTemplate>
                                        <asp:Label ID="Label7" runat="server" Text='<%# ((decimal)Eval("整车吨位"))/1000 %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                                </asp:TemplateField> 
                                
                                 <asp:TemplateField HeaderText="整车米数" SortExpression="整车米数">
                                    <ItemTemplate>
                                        <asp:Label ID="Label8" runat="server" Text='<%# (decimal)Eval("整车米数") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                                </asp:TemplateField>                                  
                                 
                                  
                                   <asp:TemplateField HeaderText="日期" SortExpression="发运时间">
                                    <ItemTemplate>
                                        <asp:Label ID="Label9" runat="server" Text='<%# Eval("发运时间","{0:d}") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                                </asp:TemplateField>  
                                
                                <asp:TemplateField HeaderText="订货单位ID" SortExpression="订货单位ID" Visible="false">
                                    <ItemTemplate>
                                        <asp:Label ID="Label10" runat="server" Text='<%# Eval("订货单位ID") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                                </asp:TemplateField>                            
                           
                                <asp:TemplateField HeaderText="判定" Visible ="false">
                                    <ItemTemplate>
                                        <img src='/Images/hege_<%# Eval("是否合格") %>.png' />
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="40px" />
                                </asp:TemplateField>                                   
                        </Columns>
                        <SelectedRowStyle CssClass="grid-row-selected" />
                      </asp:GridView>
	            </td>
            </tr>
            <tr>
	            <td>   
	                <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

	            </td>
            </tr>
        </table>
        

    </div>
</div>

</form>
<script>
    var notice = '<%=this.Notice %>';
    if (notice != '') {
        parent.showmsgbox(notice);
    }
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
            rows[i].onclick = selectRow;
        }
    }
    document.getElementById("Date1").onfocus = document.getElementById("Date2").onfocus = function() {
        makecalendar(this.value, this);
    };
    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName == "INPUT" && tag.className == "textbox" || tag.tagName == "SELECT") {
            if (e.keyCode == 13) e.keyCode = 9;
        }
    }

    var rows = document.getElementById("GridView1").rows;
    var sum1 = 0, sum2 = 0, sum3 = 0 ,sum4=0;
    for (i = 1; i < rows.length; i++) {
        sum1 += Number(rows[i].cells[6].innerText);
        sum2 += Number(rows[i].cells[7].innerText);
        sum3 += Number(rows[i].cells[8].innerText);
        sum4 += Number(fixFloat(Number(rows[i].cells[8].innerText),3));
    }
    var total = document.getElementById("Label_Total");
    total.innerHTML += "　本页小计：" + (rows.length - 1) + "单 " + sum1 + "捆 " + sum2 + "支 " + fixFloat(sum3,4) + "("+fixFloat(sum4,3)+")吨";
    
</script>
</body>
</html>
